﻿using System;
using System.Collections.Generic;
using System.ComponentModel; 
using NTTDATA.BEENChina.ResultCertification.Config;
using NTTDATA.BEENChina.ResultCertification.PropertyGridUtil.CustomObject;
using NTTDATA.BEENChina.ResultCertification.PropertyGridUtil;

namespace NTTDATA.BEENChina.ResultCertification.Checker.Numeric
{
    [Serializable]
    [VerfityAttribute(Id = "VerfityD0004", Name = "公式验证", CategoryType = EnumCategoryType.数值, Model = true)]
    public class VerfityD0004 : VerfityOneResult
    {
        private CustomCollection<ExpressionCondition> _conditions = new CustomCollection<ExpressionCondition>() { Description = "表达式条件" };

        [TypeConverter(typeof(CustomCollectionConverter<ExpressionCondition>))]
        [RefreshProperties(RefreshProperties.All)]
        public CustomCollection<ExpressionCondition> Conditions 
        {
            get { return _conditions; }
            set { _conditions = value ;}
        } 
  
        public override bool CheckResult(List<List<string>> result, string entryCommon)
        {
            try
            {
                if (entryCommon == "30" || entryCommon == "20")
                {
                    return false;
                } 
                
                return new VerfityExpression().CheckNumberExpression(result, _conditions);
            }
            catch (ExpressionErrorException exp)
            {
                throw;
            }
            catch (CellEmptyException exp)
            {
                return false;
            }
            catch (Exception exp)
            {
                return false;
            }
        }


    }
   


}